/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.indicator;

import org.amuthu.DataStore;
import org.amuthu.TalibMgr;

/**
 *
 * @author prabhu
 */
public abstract class AroonIndicator extends Indicator
{
   private int period;
   private double[] aroonUp;
   private double[] aroonDown;

   public double getAroonDown()
   {
      return roundDouble(aroonDown[0], 2);
   }

   public double getAroonUp()
   {
      return roundDouble(aroonUp[0], 2);
   }

   public AroonIndicator(DataStore dataStore, int period, int startOffset)
   {
      super(dataStore, startOffset);
      this.period = period;

      aroonUp = new double[1];
      aroonDown = new double[1];
   }

   public void doCalculate()
   {
      int lastIdx = getLastIndex();

      TalibMgr.getTalib().aroon(lastIdx,
                                lastIdx,
                                getDataStore().getHigh(),
                                getDataStore().getLow(),
                                period,
                                TalibMgr.getOutBeginIdx(),
                                TalibMgr.getOutNbElement(),
                                aroonDown,
                                aroonUp);
   }

   @Override
   public int getDayDependency()
   {
      return TalibMgr.getTalib().aroonLookback(period) + startOffset;
   }

}
